<template>
  <div class="collect">
    <div class="collect-container">
      <div class="collect-head">
        <span>默认收藏夹</span>
      </div>
      <div class="collect-body">
        <el-row class="row">
          <el-col
            :span="4"
            v-for="item in collectList"
            :key="item.id"
            class="collect-video"
          >
            <el-image
              :src="item.image"
              class="el-image"
              @click.native="toVideo(item.id)"
            ></el-image>
            <div class="title">
              <a>{{ item.title }}</a>
            </div>
            <div class="time">
              <a>收藏于:&nbsp;&nbsp;{{ item.date }}</a>
            </div>
          </el-col>
        </el-row>
      </div>
      <fab
        :actions="fabActions"
        :bg-color="bgColor"
        :main-tooltip="mainTooltip"
      ></fab>
    </div>

    <!-- <el-pagination
    @size-change="handleSizeChange"
    @current-change="handleCurrentChange"
    :page-sizes="[2, 4, 6, 8]"
    :page-size="queryinfo.size"
    layout="total, sizes, prev, ppager, next, jumper"
    :total="total">
    </el-pagination> -->
  </div>
</template>

<script>
import { getCollectList } from "@/api/userVideoApi";
import fab from "vue-fab";
export default {
  components: {
    fab,
  },
  data() {
    return {
      bgColor: "#409eff",
      mainTooltip: "创建收藏夹",
      fabActions: [],
      queryinfo: {
        no: 1,
        size: 20,
        // userId: sessionStorage.getItem("id"),
        userId: sessionStorage.getItem("id"),
      },
      collectList: [],
      total: 0,
    };
  },

  methods: {
    // 收藏列表
    getCollectList() {
      getCollectList(this.queryinfo)
        .then((res) => {
          console.log(res);
          this.collectList = res.data.data.rows;
          this.total = res.data.data.total;
        })
        .catch((error) => {
          console.log(error);
        });
    },

    //监听page，页面大小条数的改变事件
    handleSizeChange(val) {
      this.queryinfo.size = val;
      this.getCollectList();
    },

    //页码值改变的事件监听
    handleCurrentChange(val) {
      this.queryinfo.no = val;
      this.getCollectList();
    },

    toVideo(id) {
      this.$router.push({
        name: "video",
        query: {
          id: id,
        },
      });
    },
  },

  mounted() {
    this.getCollectList();
  },
};
</script>

<style>
.collect {
  width: 100%;
  min-height: 700px;
  position: relative;
}
.collect-container {
  right: 50%;
  left: 20%;
  position: absolute;
}
.collect-head {
  width: 1000px;
  height: 100px;
  margin-top: 10px;
  border-radius: 10px;
  background-color: #77baf8;
}
.collect-head span {
  font-weight: 900;
  line-height: 100px;
  padding: 5px;
}
.el-image {
  width: 200px;
  height: 120px;
}

.collect-body {
  text-align: center;
}
.collect-body .time a {
  color: #878787;
  font-size: 12px;
}
.collect-body {
  margin-top: 20px;
}
.collect-body .title a {
  font-size: 13px;
}
.collect-body .title a:hover {
  color: #00a1d6;
  cursor: pointer;
}
.collect-video {
  width: 205px;
  margin-right: 20px;
}
.collect-video .title {
  height: 40px;
}

.row {
  width: 1000px;
}
</style>